'''WebDriver 常用方法'''

from selenium import webdriver
driver =webdriver.Chrome()
web_url = 'https://www.baidu.com'
driver.get(web_url)

'''
# 通过定位ID，定位文本框。并清除文本框文本
driver.find_element_by_id('kw').clear()

# 模拟按键输入
driver.find_element_by_id('kw').send_keys('selenium')

# 单击元素
# driver.find_element_by_id('su').click()

#submit()用户提交表单，例如，在搜索框输入关键字后，回车
driver.find_element_by_id('kw').submit()
'''

# 获取文本框尺寸
input_size = driver.find_element_by_id('kw').size
print(input_size)

# 获取百度首页备案信息
baidu_beian = driver.find_element_by_id('jgwab').text
print(baidu_beian)

# 获取”百度一下“按钮属性值
attribute = driver.find_element_by_id('su').get_attribute('value')
print(attribute)

# 返回元素的结果是否可见，返回结果为true或false
result = driver.find_element_by_id('kw').is_displayed()
print(result)
# driver.quit()
